local key = KEYS[1]
local count = ARGV[1]
local array = {}
for i=1, count, 1 do

    local lvalue = redis.call("rpop", key)
    if (not lvalue) then
        break
    end
    local hvalue = redis.call("hmget", "SMInfo:"..lvalue, "Srv_node", "ServiceCode", "SmType", "User", "Smcont", "Reportflag", "recvTime", "RecvModuleName", "SendPort", "SerialSegment", "resptime", "respresult", "OrgSrvNode", "OrgSerialNo", "SendFeedbackResult")
    table.insert(hvalue, lvalue)
    array[i] = hvalue
    
    redis.call("del", "SMInfo:"..lvalue)
    
end
return array